<template>
	<view class="page">
		<view class="card">
			<view class="card-title">我的钱包（元）</view>
			<view class="card-content flex">
				<view class="card-price"><text style="font-size: 24rpx;font-weight: bold;margin-right: 6rpx;">￥</text>{{ usermsg.money }}</view>
				<view class="card-btn" @click="apifun.navigate('/pages/my/withdraw')">我要提现</view>
			</view>
		</view>
		<view class="main">
			<view class="main-title">钱包明细</view>
			<view class="main-list">
				<view class="main-item" v-for="(item,index) in list" :key="index">
					<view class="item-title flex">
						<view class="item-name">{{ item.title }}：{{ item.amount }}</view>
						<view class="item-money">{{ item.amount }}</view>
					</view>
					<view class="item-timer">订单号：{{ item.order_sn }}</view>
					<view class="item-timer">{{ item.create_time }}</view>
					<view class="item-tips">余额：{{ item.after }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				usermsg:{},
				list: [],
			};
		},
		onLoad() {
			this.usermsg = uni.getStorageSync('usermsg');
			this.initData();
		},
		onShow() {
			this.usermsgfun()
		},
		methods: {
			initData(){
				let sendData = {
					page:this.page,
					limit:this.apifun.limit
				};
				this.apifun.unirequest('/partner/user/getMoneyRecord','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						if(datas.list.data.length <= 0){
							this.page--;
							return false
						};
						this.list = [...this.list,...datas.list.data];
						this.usermsg.money = datas.money;
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			usermsgfun(){
				this.apifun.unirequest('/partner/user/getUserInfo','post',{},(res)=>{
					if(res.code === 200){
						let datas = res.data;
						uni.setStorageSync('usermsg', datas);
						this.usermsg = datas;
					}else{
						this.apifun.toast(res.msg)
					}
				},true)
			},
		},
		onReachBottom() {
			this.page++;
			this.initData()
		},
		onPullDownRefresh() {
			this.page = 1;
			this.list = [];
			this.initData()
			uni.stopPullDownRefresh()
		}
	}
</script>

<style lang="scss" scoped>
	.card{
		width: 100%;
		height: 260rpx;
		background-image: url('@/static/my/bg.png');
		background-size: cover;
		padding: 70rpx 60rpx 0 64rpx;
		.card-title{
			font-size: 28rpx;
		}
		.card-content{
			margin-top: 20rpx;
			justify-content: space-between;
			.card-price{
				font-size: 60rpx;
				// font-weight: bold;	
			}
			.card-btn{
				width: 124rpx;
				height: 44rpx;
				line-height: 44rpx;
				text-align: center;
				font-size: 24rpx;
				color: #FFFFFF;
				border-radius: 10rpx;
				background: #0E71EB;
			}
		}
	}
	.main{
		margin: 30rpx;
		border-radius: 30rpx 30rpx 0px 0px;
		.main-title{
			font-size: 30rpx;
			font-weight: bold;
			margin-bottom: 20rpx;
		}
		.main-list{
			border-radius: 10px;
			background: #FFFFFF;
		}
		.main-item{
			margin: 0 30rpx 0 24rpx;
			padding-bottom: 24rpx;
			border-bottom: 1rpx solid #F7F7F7;
			.item-title{
				justify-content: space-between;
				padding-top: 24rpx;
				.item-name{
					font-size: 30rpx;
				}
				.item-money{
					font-size: 40rpx;
					font-weight: bold;
				}
			}
			.item-timer{
				margin-top: 6rpx;
				color: #9E9E9E;
				font-size: 24rpx;
			}
			.item-tips{
				display: inline-block;
				color: #0E71EB;
				margin-top: 12rpx;
				height: 40rpx;
				line-height: 40rpx;
				border-radius: 6rpx;
				box-sizing: border-box;
				border: 1rpx solid #0E71EB;
				padding: 0 10rpx;
			}
		}
	}
</style>
